//
//  HavePayedTradeRecordTableViewCell.m
//  ZYZB
//
//  Created by ENERGY on 2018/7/9.
//  Copyright © 2018年 ENERGY. All rights reserved.
//

#import "HavePayedTradeRecordTableViewCell.h"

@interface HavePayedTradeRecordTableViewCell()
@property (nonatomic, strong)UILabel * profitTitleLab;//到期收益标题
@property (nonatomic, strong)UILabel * profitContentLab;//到期收益
@property (nonatomic, strong)UILabel * lendRateTitleLab;//出借率标题
@property (nonatomic, strong)UILabel * lendRateContentLab;//出借率
@property (nonatomic, strong)UILabel * projectLab;//项目名称
@property (nonatomic, strong)UILabel * dateLab;//日期
@property (nonatomic, strong)UIButton * interestBtn;//查看月息
@property (nonatomic, strong)NSString * bidID;//标的ID
@end
@implementation HavePayedTradeRecordTableViewCell

- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        __weak typeof (self)weakSelf = self;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.profitTitleLab];
        [self.contentView addSubview:self.profitContentLab];
        [self.contentView addSubview:self.lendRateTitleLab];
        [self.contentView addSubview:self.lendRateContentLab];
        [self.contentView addSubview:self.projectLab];
        [self.contentView addSubview:self.dateLab];
        [self.contentView addSubview:self.interestBtn];
        UIView * lineViw = [[UIView alloc] init];
        lineViw.backgroundColor = getColor(grayColor);
        [self.contentView addSubview:lineViw];
        [lineViw mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(weakSelf.contentView.mas_bottom);
            make.height.mas_offset(1/WIDTH_6_SCALE);
            make.left.equalTo(weakSelf.contentView.mas_left).mas_offset(18/WIDTH_6_SCALE);
            make.right.equalTo(weakSelf.contentView.mas_right).mas_offset(-18/WIDTH_6_SCALE);
        }];
        [self.profitTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView.mas_left).mas_offset(18/WIDTH_6_SCALE);
            make.top.equalTo(weakSelf.contentView.mas_top).mas_offset(21/WIDTH_6_SCALE);
        }];
        [self.profitContentLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.profitTitleLab.mas_bottom).mas_offset(15/WIDTH_6_SCALE);
            make.left.equalTo(weakSelf.profitTitleLab);
        }];
        [self.projectLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.profitContentLab.mas_left);
            make.top.equalTo(weakSelf.profitContentLab.mas_bottom).mas_offset(21/WIDTH_6_SCALE);
            make.bottom.equalTo(lineViw.mas_top).mas_offset(-16/WIDTH_6_SCALE);
        }];
        [self.lendRateTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.profitTitleLab.mas_right).mas_offset(68/WIDTH_6_SCALE);
            make.top.height.equalTo(weakSelf.profitTitleLab);
        }];
        [self.lendRateContentLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(weakSelf.lendRateTitleLab);
            make.top.height.equalTo(weakSelf.profitContentLab);
        }];
        [self.interestBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(weakSelf.dateLab);
            make.top.equalTo(weakSelf.profitTitleLab);
            make.width.mas_offset(64/WIDTH_6_SCALE);
            make.height.mas_offset(28/WIDTH_6_SCALE);
        }];
        [self.dateLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.height.equalTo(weakSelf.projectLab);
            make.right.equalTo(weakSelf.contentView.mas_right).mas_offset(-18/WIDTH_6_SCALE);
        }];
    }return self;
}
- (UILabel *)profitTitleLab{
    if (!_profitTitleLab) {
        _profitTitleLab = [[UILabel alloc] init];
        _profitTitleLab.font = DEF_FontSize_10;
        _profitTitleLab.textColor = [UIColor blackColor];
        _profitTitleLab.textAlignment = NSTextAlignmentLeft;
        _profitTitleLab.text = @"到期收益(元)";
//        _profitTitleLab.backgroundColor = [UIColor orangeColor];
    }return _profitTitleLab;
}
- (UILabel *)profitContentLab{
    if (!_profitContentLab) {
        _profitContentLab = [[UILabel alloc] init];
        _profitContentLab.font = DEF_FontSize_14;
        _profitContentLab.textColor = [UIColor orangeColor];
        _profitContentLab.textAlignment = NSTextAlignmentLeft;
        _profitContentLab.text = @"13,660.73";
    }return _profitContentLab;
}
- (UILabel *)projectLab{
    if (!_projectLab) {
        _projectLab = [[UILabel alloc] init];
        _projectLab.font = DEF_FontSize_12;
        _projectLab.textColor = [UIColor blackColor];
        _projectLab.textAlignment = NSTextAlignmentLeft;
        _projectLab.text = @"【家家泰365天J16062141】";
    }return _projectLab;
}
- (UILabel *)lendRateTitleLab{
    if (!_lendRateTitleLab) {
        _lendRateTitleLab = [[UILabel alloc] init];
        _lendRateTitleLab.font = DEF_FontSize_10;
        _lendRateTitleLab.textColor = [UIColor blackColor];
        _lendRateTitleLab.textAlignment = NSTextAlignmentCenter;
        _lendRateTitleLab.text = @"平台建议年均出借率";
    }return _lendRateTitleLab;
}
- (UILabel *)lendRateContentLab{
    if (!_lendRateContentLab) {
        _lendRateContentLab = [[UILabel alloc] init];
        _lendRateContentLab.font = DEF_FontSize_14;
        _lendRateContentLab.textColor = [UIColor orangeColor];
        _lendRateContentLab.textAlignment = NSTextAlignmentCenter;
        _lendRateContentLab.text = @"10.0%";
    }return _lendRateContentLab;
}
-  (UIButton *)interestBtn{
    if (!_interestBtn) {
        _interestBtn = [[UIButton alloc] init];
        _interestBtn.titleLabel.font = DEF_FontSize_10;
        [_interestBtn setTitle:@"查看月息" forState:UIControlStateNormal];
        [_interestBtn setBackgroundColor:[UIColor clearColor]];
        [_interestBtn setTitleColor:getColor(@"ff8819") forState:UIControlStateNormal];
        _interestBtn.layer.borderColor = getColor(@"ff8819").CGColor;
        _interestBtn.layer.borderWidth = 1;
        _interestBtn.layer.cornerRadius = 6;
        _interestBtn.layer.masksToBounds = YES;
    }return _interestBtn;
}
- (UILabel *)dateLab{
    if (!_dateLab) {
        _dateLab = [[UILabel alloc] init];
        _dateLab.font = DEF_FontSize_12;
        _dateLab.textColor = getColor(@"bdbdbd");
        _dateLab.textAlignment = NSTextAlignmentCenter;
        _dateLab.text = @"到期时间2018-12-12";
    }return _dateLab;
}
- (void)setModel:(NSDictionary *)model{
    _model = model;
    self.profitContentLab.text = model[@"earnings"];
    self.lendRateContentLab.text = model[@"sulimit"];
    self.projectLab.text = [NSString stringWithFormat:@"【%@】", model[@"productName"]];
    self.dateLab.text = model[@"subjectTerm"];
    self.bidID = model[@"bid"];
}
@end
